package com.ljf.daily.makemoneysoftware.api.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ljf.common.api.service.impl.BasisServiceImpl;
import com.ljf.common.exception.ServiceException;
import com.ljf.common.result.ServiceResultModel;
import com.ljf.common.utils.ServiceResultUtil;
import com.ljf.daily.makemoneysoftware.domain.repository.DailyDatMakeMoneySoftwareRepository;
import com.ljf.daily.makemoneysoftware.domain.service.DailyDatMakeMoneySoftwareDomainService;
import com.ljf.daily.makemoneysoftware.domain.validator.DailyDatMakeMoneySoftwareValidator;
import com.ljf.daily.makemoneysoftware.dto.command.DailyDatMakeMoneySoftwareCommand;
import com.ljf.daily.makemoneysoftware.dto.command.DailyDatMakeMoneySoftwareConfigCommand;
import com.ljf.daily.makemoneysoftware.dto.query.DailyDatMakeMoneySoftwareQuery;
import com.ljf.daily.makemoneysoftware.model.DailyDatMakeMoneySoftware;
import com.ljf.daily.makemoneysoftware.service.IDailyDatMakeMoneySoftwareService;
import com.ljf.daily.makemoneysoftware.vo.DailyDatMakeMoneySoftwareConfigVO;
import com.ljf.daily.makemoneysoftware.vo.DailyDatMakeMoneySoftwareVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 赚钱软件定义  服务接口实现
 *
 * @author LJF
 * @since 2024-02-26
 */
@Service
public class DailyDatMakeMoneySoftwareServiceImpl extends BasisServiceImpl<DailyDatMakeMoneySoftwareDomainService, DailyDatMakeMoneySoftwareValidator, DailyDatMakeMoneySoftwareRepository, DailyDatMakeMoneySoftwareQuery, DailyDatMakeMoneySoftwareVO, DailyDatMakeMoneySoftware, DailyDatMakeMoneySoftwareCommand> implements IDailyDatMakeMoneySoftwareService {

    /**
     * 更新配置
     *
     * @param command
     * @return
     * @throws ServiceException
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public ServiceResultModel editConfig(DailyDatMakeMoneySoftwareConfigCommand command) throws ServiceException {
        validator.checkEditConfig(command);
        domainService.editConfig(command);
        return ServiceResultUtil.success();
    }

    /**
     * 配置分页查询
     *
     * @param query
     * @return
     * @throws ServiceException
     */
    @Override
    public ServiceResultModel<DailyDatMakeMoneySoftwareConfigVO> queryConfig(DailyDatMakeMoneySoftwareQuery query) throws ServiceException {
        validator.checkQueryConfig(query);
        Page<DailyDatMakeMoneySoftwareConfigVO> page = domainService.queryConfig(query);
        return ServiceResultUtil.success(page);
    }

    /**
     * 新增执行软件查询
     *
     * @param query
     * @return
     * @throws ServiceException
     */
    @Override
    public ServiceResultModel<DailyDatMakeMoneySoftwareVO> queryListExecuteInsert(DailyDatMakeMoneySoftwareQuery query) throws ServiceException {
        List<DailyDatMakeMoneySoftwareVO> resultList = domainService.queryListExecuteInsert(query);
        return ServiceResultUtil.success(resultList);
    }

}
